package com.ruoyi.ftrl.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ftrl.domain.RateInfo;
import com.ruoyi.ftrl.service.IRateInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 费率设置信息Controller
 * 
 * @author ruoyi
 * @date 2024-07-24
 */
@RestController
@RequestMapping("/ftrl/rate")
public class RateInfoController extends BaseController
{
    @Autowired
    private IRateInfoService rateInfoService;

    /**
     * 查询费率设置信息列表
     */
    @PreAuthorize("@ss.hasPermi('ftrl:rate:list')")
    @GetMapping("/list")
    public TableDataInfo list(RateInfo rateInfo)
    {
        startPage();
        List<RateInfo> list = rateInfoService.selectRateInfoList(rateInfo);
        return getDataTable(list);
    }

    /**
     * 导出费率设置信息列表
     */
    @PreAuthorize("@ss.hasPermi('ftrl:rate:export')")
    @Log(title = "费率设置信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RateInfo rateInfo)
    {
        List<RateInfo> list = rateInfoService.selectRateInfoList(rateInfo);
        ExcelUtil<RateInfo> util = new ExcelUtil<RateInfo>(RateInfo.class);
        util.exportExcel(response, list, "费率设置信息数据");
    }

    /**
     * 获取费率设置信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('ftrl:rate:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(rateInfoService.selectRateInfoById(id));
    }

    /**
     * 新增费率设置信息
     */
    @PreAuthorize("@ss.hasPermi('ftrl:rate:add')")
    @Log(title = "费率设置信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RateInfo rateInfo)
    {
        return toAjax(rateInfoService.insertRateInfo(rateInfo));
    }

    /**
     * 修改费率设置信息
     */
    @PreAuthorize("@ss.hasPermi('ftrl:rate:edit')")
    @Log(title = "费率设置信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RateInfo rateInfo)
    {
        return toAjax(rateInfoService.updateRateInfo(rateInfo));
    }

    /**
     * 删除费率设置信息
     */
    @PreAuthorize("@ss.hasPermi('ftrl:rate:remove')")
    @Log(title = "费率设置信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(rateInfoService.deleteRateInfoByIds(ids));
    }
}
